package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.HotelProducts;
import cn.wolfcode.trip.base.domain.User;
import cn.wolfcode.trip.base.query.HotelQueryObjext;
import cn.wolfcode.trip.base.service.IHotelProductsService;
import cn.wolfcode.trip.base.service.IUserService;
import cn.wolfcode.trip.base.util.JsonResult;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/hotelProducts")
public class HotelProductsController {
    @Autowired
    private IHotelProductsService productsService;

    @Autowired
    private IUserService userService;

    //获取当前用户信息
    @GetMapping("/user/{userId}")
    public User getUser(@PathVariable Long userId){
        User user= userService.get(userId);
        return user;
    }

    //增加信息
   @PostMapping
    public JsonResult adds(HotelProducts products){
        productsService.save(products);

        return new JsonResult();
    }
    //查询
   @GetMapping
    public PageInfo gets(HotelQueryObjext qo){
       PageInfo list= productsService.qeury(qo);
        return list;
    }

    //修改
    @PostMapping("/put")
    public void updata(HotelQueryObjext qo){
        //查询当前酒店信息的销售量 并让它自增1

        productsService.put(qo);
    }



}
